<?php
/**
 * appRain v 0.1.x
 *
 * LICENSE
 *
 * This source file is subject to the MIT license that is bundled
 * with this package in the file LICENSE.txt.
 * It is also available through the world-wide-web at this URL:
 * http://www.opensource.org/licenses/mit-license.php
 * If you did not receive a copy of the license and are unable to
 * obtain it through the world-wide-web, please send an email
 * to license@apprain.com so we can send you a copy immediately.
 *
 * @copyright  Copyright (c) 2010 appRain, Inc. (http://www.apprain.com)
 * @license    http://www.opensource.org/licenses/mit-license.php MIT license
 *
 * HELP
 * 
 * Official Website 
 * http://www.apprain.com/
 *
 * Download Link
 * http://www.apprain.com/download
 *
 * Documents Link
 * http ://www.apprain.com/documents
 */

class Development_Helper_Api_Versionupdate {
    
    
    /**
     * HelloWorld::__construct() HelloWorld class Constructor.
     *
     * @param string $nombre
     * @return string
     **/
    public function __construct($name = 'World') {
        $this->name = $name;
    }

    /**
     * Comments will go there 
     *
     * @param string $appRainVersion
     * @param string $apikey
     * @return int
     */
    public function checkupdate($apikey = "", $appRainVersion = "0.1.0")
    {				
        if( $apikey != '0123456789101112') return 0;
        else if ( $appRainVersion >= '0.1.2' ) return 1;
        else return 2;
    }
    
    /**
     * Get Next Version
     * 
     * @param string $odlversion
     * @return string
     */
    public function getNewVersion($odlversion)
    {
        if( $odlversion == "0.1.0" )return '0.1.1';
        if( $odlversion == "0.1.1" )return '0.1.2';
        else return  "NoUpdateAvailable";
    }
    
    /**
     * Comments will go there 
     * @param string $version
     * @return string
     */
    public function getDefinition($version)
    {  
    	return App::Load('Helper/Utility')->fetchFile(DATA . "/versions/{$version}/definition/definition.xml");
    }

    /**
     * Comments will go there 
     *
     * @param string $version
     * @param string $code
     * @return string
     */
    public function download($version,$code)
    {
       return App::Load('Helper/Utility')->fetchFile(DATA . "/versions/{$version}/code/{$code}");
    }
}
?>